export default {
	title: '病例数前5的诊断',
	// chart数据的查询配置
	query: {
		url: 'doctor/statistic?type=0',
		method: 'GET',
		transfer: true
	},
	// ECharts的基本options配置
	options: {
		legend: {
			data: ['诊断病例数量'],
			tooltip: {
				show: true
			},
			orient: 'vertical',
			left: 'left',
			textStyle: {
				fontFamily : 'STHeiti',
				fontSize : '12',
				color:"#000000"
			},
		},
		tooltip: {},
		series: [{
			name: '诊断病例数量',	// 对于单数据的图表，wt-charts组件会自动更新到series[0]
			type: 'pie',	// 在此指定图表类型
			data: [],	// 默认为空，因为该数据是查询所得
			barWidth: '40%',
		}],
	},
	customData: function(data) {
		let total = 0;
		let top = 0;
		let series = [];
		let legend = [];
		let a;
		for (let item in data) {
			for (let i in data[item]){
				if (i == 'total_num'){
					total = data[item][i];
				}else {
					if (i.indexOf('["')!=-1){
						a = i.replace('["','')
						a = a.replace('"]','')
					}else {
						a = i
					}
					legend.push(a);
					series.push({
						value:data[item][i],
						name:a
					})
					top = top+data[item][i];
				}
			}
		}
		series.push({
			value:total-top,
			name:'其他',
		})
		legend.push('其他');
		let options = {
			series: {
				name: '诊断病例数量',
				data: series,
				fontFamily: 'Microsoft YaHei'
			},
			legend: {
				data: legend
			}
		};
		return options;
	}
};